package com.longxi.tianjintianbao.ui.presenter.assetscheck;

import android.content.Intent;
import android.view.View;

import com.longxi.tianjintianbao.AppConst;
import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.base.BasePresenter;
import com.longxi.tianjintianbao.ui.view.assetscheck.IAssetsDetailAtView;
import com.longxi.tianjintianbao.utils.LogUtils;
import com.longxi.tianjintianbao.utils.MyUtils;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.entity.LocalMedia;

public class AssetsDetailAtPresenter extends BasePresenter<IAssetsDetailAtView> {

    private String state;

    public AssetsDetailAtPresenter(BaseActivity context) {
        super(context);
    }

    public void setBar() {
        mContext.setTitle("资产盘点");
        mContext.setTvLeft(MyUtils.getString(R.string.back));
        state = mContext.getIntent().getStringExtra(AppConst.STATE);
    }

    public void onDestroy() {
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case PictureConfig.CHOOSE_REQUEST:
                // 图片选择结果回调
                addPicUtils.selectList = PictureSelector.obtainMultipleResult(data);
                // 例如 LocalMedia 里面返回三种path
                // 1.media.getPath(); 为原图path
                // 2.media.getCutPath();为裁剪后path，需判断media.isCut();是否为true
                // 3.media.getCompressPath();为压缩后path，需判断media.isCompressed();是否为true
                // 如果裁剪并压缩了，已取压缩路径为准，因为是先裁剪后压缩的
                for (LocalMedia media : addPicUtils.selectList) {
                    LogUtils.i("图片-----》", media.getPath());
                }
                gridImageAdapter.setList(addPicUtils.selectList);
                gridImageAdapter.notifyDataSetChanged();
                break;
        }
    }

    /**
     *
     * @param state
     */
    public void showBtn(int state) {
        switch (state) {
            case 0:
                getView().getLlBtn().setVisibility(View.VISIBLE);
                getView().getBtnSubmit().setVisibility(View.VISIBLE);
                getView().getBtnRepair().setVisibility(View.VISIBLE);
                break;
            case 1:
                getView().getLlBtn().setVisibility(View.VISIBLE);
                getView().getBtnSubmit().setVisibility(View.VISIBLE);
                getView().getBtnRepair().setVisibility(View.GONE);
                break;
        }
    }
}
